package com.yupi.yuoj.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yupi.yuoj.model.dto.contest.ContestAddRequest;
import com.yupi.yuoj.model.dto.contest.ContestEditRequest;
import com.yupi.yuoj.model.dto.contest.ContestQueryRequest;
import com.yupi.yuoj.model.dto.contest.ContestRegistrationRequest;
import com.yupi.yuoj.model.entity.Contest;
import com.yupi.yuoj.model.entity.ContestRegistration;
import com.yupi.yuoj.model.vo.ContestVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 竞赛服务
 */
public interface ContestService extends IService<Contest> {
    
    /**
     * 校验竞赛
     *
     * @param contest
     * @param add
     */
    void validContest(Contest contest, boolean add);

    /**
     * 获取查询条件
     *
     * @param contestQueryRequest
     * @return
     */
    QueryWrapper<Contest> getQueryWrapper(ContestQueryRequest contestQueryRequest);

    /**
     * 获取竞赛封装
     *
     * @param contest
     * @param request
     * @return
     */
    ContestVO getContestVO(Contest contest, HttpServletRequest request);

    /**
     * 分页获取竞赛封装
     *
     * @param contestPage
     * @param request
     * @return
     */
    Page<ContestVO> getContestVOPage(Page<Contest> contestPage, HttpServletRequest request);

    /**
     * 添加竞赛
     *
     * @param contestAddRequest
     * @param request
     * @return
     */
    long addContest(ContestAddRequest contestAddRequest, HttpServletRequest request);

    /**
     * 更新竞赛
     *
     * @param contestEditRequest
     * @param request
     * @return
     */
    boolean updateContest(ContestEditRequest contestEditRequest, HttpServletRequest request);

    /**
     * 用户注册竞赛
     *
     * @param contestRegistrationRequest
     * @param request
     * @return
     */
    ContestRegistration registerContest(ContestRegistrationRequest contestRegistrationRequest, HttpServletRequest request);

    /**
     * 获取用户已注册的竞赛
     * 
     * @param userId
     * @return
     */
    List<ContestVO> getRegisteredContests(Long userId, HttpServletRequest request);

    /**
     * 更新竞赛状态
     * 
     * @param contest
     * @return
     */
    boolean updateContestStatus(Contest contest);
}
